package com.zm.product.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.zm.product.model.Product;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

/**
 * TCC 二阶段提交业务接口
 */
@LocalTCC
public interface IProductTCCService   extends IService<Product> {

    /**
     * try-预扣款
     */
    @TwoPhaseBusinessAction(name="reduceStock", commitMethod = "confirm", rollbackMethod = "cancel")
    Boolean reduceStock(@BusinessActionContextParameter(paramName = "id") Long id);
    /**
     * confirm-提交
     * @param ctx
     * @return
     */
    boolean confirm(BusinessActionContext ctx);
    /**
     * cancel-回滚
     * @param ctx
     * @return
     */
    boolean cancel(BusinessActionContext ctx);
}
